<template>
    <img :src="require('../../assets/image/fileicon/'+matchPicture(value)+'.png')" class="fileicon" />
</template>
<script>
    export default {
        props: {
            value: {
                type: String,
                default: "12"
            },
        },
        mounted() {},
        data() {
            return {
                fileSuffix: ['asp', 'c', 'cpp', 'css', 'dat', 'dmp', 'doc', 'docx', 'dot', 'exe', 'h', 'html', 'ics',
                    'iso', 'java', 'key', 'odp', 'ods', 'odt', 'otp', 'ott', 'pb', 'pdf', 'php', 'pps', 'ppt', 'py',
                    'rar', 'rtf', 'sql', 'tgz', 'txt', 'xml', 'yml', 'zip'
                ]
            }
        },
        methods: {
            matchPicture(name) {
                let suffix = ''
                try {
                    let fileArr = name.split('.')
                    suffix = fileArr[fileArr.length - 1]
                    if (this.$isNotEmpty(suffix)) {
                        // console.log(suffix.toLowerCase())
                        if (!this.fileSuffix.includes(suffix.toLowerCase())) {
                            suffix = 'unknow'
                        }else{
                            console.log("找到图标"+suffix)
                        }
                    } else {
                        suffix = 'unknow'
                    }
                } catch (error) {
                    suffix = 'unknow'
                }
                return suffix
            }
        }
    }
</script>
<style scoped>
    .fileicon {
        user-select: none;
    }
</style>